<!doctype html>
{% extends "base.html" %}
{% block title %}用户组管理{% endblock title %}

{% block page5_show %}show{% endblock page5_show %}
{% block page5.2_active %}active{% endblock page5.2_active %}

{% load Domain_filter %}

{% block main_content %}

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <div class="float-right">
                        <small style="margin-right: 20px;"><a href="/refresh_group">重新获取</a></small>
                        <small><a href="" data-toggle="modal" data-target="#addgroup">添加组</a></small>
                        <div class="modal fade" id="addgroup" tabindex="-1" role="dialog" aria-hidden="true">
                            <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h1 class="modal-title">新建用户组</h1>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    </div>
                                    <div class="modal-body m-3">
                                            <form method="post" action="/add_group">

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">用户组名称</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" name="group" class="form-control" value="">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">资产管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="HostManager" class="form-control" value="000">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">主机管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="HostSetting" class="form-control" value="000">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">应用操作</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="AppManager" class="form-control" value="00000">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">应用监控</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="AppMonitor" class="form-control" value="000">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">日志统计</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="Logs" class="form-control" value="0000">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">用户管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="UserManager" class="form-control" value="000">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">域名管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="DomainManager" class="form-control" value="00">
                                                    </div>
                                                </div>

										        <div class="modal-footer">
                                                    <div class="col-sm-12 ml-sm-auto">
                                                        <button type="button" class="btn btn-secondary float-left" data-dismiss="modal">关闭</button>
                                                        <button type="submit" class="btn btn-primary float-right" >添加</button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                </div>
                            </div>
                        </div>
                </div>
                <h5 class="card-title">用户列表</h5>
                <h6 class="card-subtitle text-muted">用户列表以及对应的权限，权限号码对应菜单的第几个选项是否可用，不可用为0</h6>
                
            </div>
            <table class="table table-striped table-hover table-bordered">
                <thead>
                    <tr style="text-align: center;">
                        <th>用户组</th>
                        <th>资产管理</th>
                        <th>主机管理</th>
                        <th>应用操作</th>
                        <th>应用监控</th>
                        <th>日志统计</th>
                        <th>用户管理</th>
                        <th>域名管理</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody  style="text-align: center;">
                    {% for group,groupdata in UserGroup.items %}
                    <tr>
                        <td style="width: 5%;">{{ group }}</td>
                        <td style="width: 5%;">{{ groupdata.HostManager }}</td>
                        <td style="width: 5%;">{{ groupdata.HostSetting }}</td>
                        <td style="width: 5%;">{{ groupdata.AppManager }}</td>
                        <td style="width: 5%;">{{ groupdata.AppMonitor }}</td>
                        <td style="width: 5%;">{{ groupdata.Logs }}</td>
                        <td style="width: 5%;">{{ groupdata.UserManager }}</td>
                        <td style="width: 5%;">{{ groupdata.DomainManager }}</td>
                        <td class="table-action" style="width: 5%;">
                            <a href="" style="margin-right: 10px;"  data-toggle="modal" data-target="#set{{ group }}"><i class="fe fe-edit-2"></i></a>
                            <div class="modal fade" id="set{{ group }}" tabindex="-1" role="dialog" aria-hidden="true">
                                <div class="modal-dialog modal-dialog-centered" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h1 class="modal-title">修改用户组权限：{{ group }}</h1>
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        </div>
                                        <div class="modal-body m-3">
                                            <form method="post" action="/users_manager">

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">用户组名称</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" name="group" class="form-control" readonly="readonly" value="{{ group }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">资产管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="HostManager" class="form-control" value="{{ groupdata.HostManager }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">主机管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="HostSetting" class="form-control" value="{{ groupdata.HostSetting }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">应用操作</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="AppManager" class="form-control" value="{{ groupdata.AppManager }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">应用监控</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="AppMonitor" class="form-control" value="{{ groupdata.AppMonitor }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">日志统计</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="Logs" class="form-control" value="{{ groupdata.Logs }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">用户管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="UserManager" class="form-control" value="{{ groupdata.UserManager }}">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">域名管理</label>
                                                    <div class="col-sm-6">
                                                        <input type="number" name="DomainManager" class="form-control" value="{{ groupdata.DomainManager }}">
                                                    </div>
                                                </div>

										        <div class="modal-footer">
                                                    <div class="col-sm-12 ml-sm-auto">
                                                        <button type="button" class="btn btn-secondary float-left" data-dismiss="modal">关闭</button>
                                                        <button type="submit" class="btn btn-primary float-right" >修改</button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <a href="" data-toggle="modal" data-target="#del{{ group }}"><i class="fe fe-trash"></i></a>
                            <div class="modal fade" id="del{{ group }}" tabindex="-1" role="dialog" aria-hidden="true">
								<div class="modal-dialog modal-dialog-centered" role="document">
									<div class="modal-content">
										<div class="modal-header">
											<h1 class="modal-title">是否删除组： {{ group }}</h1>
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							                    <span aria-hidden="true">&times;</span>
							                  </button>
										</div>
                                        <form method="post" action="/del_group">
                                        <div class="modal-body m-3">
                                            <div class="form-group row">
                                                <label class="col-form-label col-sm-4 text-sm-right">将删除用户组</label>
                                                <div class="col-sm-8">
                                                    <input type="text" name="group" value="{{ group }}" readonly="readonly"  class="form-control">
                                                </div>
                                            </div>
											<p class="mb-0">删除后无法恢复，请慎重，点击 弹窗外/X按钮/取消按钮 可取消</p>
									    </div>
										<div class="modal-footer">
											<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
											<button type="submit" class="btn btn-danger">删除</button>
										</div>
                                        </form>
									</div>
								</div>
							</div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock main_content %}

{% block script %}
{% endblock script %}